<?php
namespace app\shop\model;

use app\BaseModel;
use think\facade\Db;

class DistributionGoods extends BaseModel
{



    protected $name = 'lbfarm_v2_distribution_goods_list';




    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:04
     * @功能说明:添加
     */
    public function dataAdd($data){

        $res = $this->insert($data);

        return $res;

    }



    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:05
     * @功能说明:编辑
     */
    public function dataUpdate($dis,$data){

        $res = $this->where($dis)->update($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:06
     * @功能说明:列表
     */
    public function dataList($dis,$page){

        $data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();

        return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:43
     * @功能说明:
     */
    public function dataInfo($dis){

        $data = $this->where($dis)->find();

        return !empty($data)?$data->toArray():[];

    }


    /**
     * @author chenniang
     * @DataTime: 2022-07-27 17:46
     * @功能说明:获取商城商品
     */
    public function getShopGoods($cash_id){

        $dis = [

            'a.cash_id' => $cash_id
        ];

        $data = $this->alias('a')
                ->join('lbfarm_shop_order_goods b','a.order_goods_id = b.id')
                ->where($dis)
                ->field('b.goods_name,b.goods_cover,b.spe_name,b.pay_price,a.*,b.singe_pay_price')
                ->group('a.id')
                ->select()
                ->toArray();

        return $data;
    }


    /**
     * @author chenniang
     * @DataTime: 2022-07-27 17:54
     * @功能说明:获取土地商品
     */
    public function getLandGoods($cash_id){

        $dis = [

            'a.cash_id' => $cash_id
        ];

        $data = $this->alias('a')
            ->join('lbfarm_land_order b','a.order_goods_id = b.id')
            ->where($dis)
            ->field('b.goods_name,b.goods_cover,b.spe_name,b.pay_price,a.*,b.pay_price as singe_pay_price ')
            ->group('a.id')
            ->select()
            ->toArray();

        return $data;
    }



    /**
     * @author chenniang
     * @DataTime: 2022-07-27 17:54
     * @功能说明:获取认养商品
     */
    public function getCliamGoods($cash_id){

        $dis = [

            'a.cash_id' => $cash_id
        ];

        $data = $this->alias('a')
            ->join('lbfarm_claim_order b','a.order_goods_id = b.id')
            ->where($dis)
            ->field('b.goods_name,b.goods_cover,b.spe_name,b.pay_price,a.*,b.pay_price as singe_pay_price')
            ->group('a.id')
            ->select()
            ->toArray();

        return $data;
    }









}